package com.lily.ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lily.ssm.mapper.NewsMapper;
import com.lily.ssm.model.News;

@Service
public class NewsService {
	@Autowired
	private NewsMapper newsMapper;
	
	//分页查询所有News
	public List<News> selectNews(int offset){
		return newsMapper.selectAllNews(offset);
	}
	
	//查询共有多少条News数据
	public int getNewsCount(){
		return newsMapper.getNewsCount();
	}
	
	//添加新闻信息
	public int insertNews(News news){
		return newsMapper.insertSelective(news);
	}
	
	//根据newsId查询整条News信息
	public News getNews(int newsId){
		return newsMapper.selectByPrimaryKey(newsId);
	}
	
	//修改新闻信息
	public int updateNews(News news){
		return newsMapper.updateByPrimaryKeySelective(news);
	}
	
	//根据newsId删除信息
	public int deleteNews(int newsId){
		return newsMapper.deleteByPrimaryKey(newsId);
	}
}
